Skip to content

fix: allow multistage Dockerfiles by removing AS <stage name> in validation#112

Merged
arnaugiralt merged 4 commits intomasterfrom
issue-103-allow-multistage
Feb 28, 2026
Merged

fix: allow multistage Dockerfiles by removing AS <stage name> in validation#112
arnaugiralt merged 4 commits intomasterfrom
issue-103-allow-multistage

Conversation

@Sainomori
Copy link
Copy Markdown
Contributor

@Sainomori Sainomori commented May 28, 2024

fixes #103

  • Modified the validate_docker_compose_yml function to support multistage Dockerfiles.
  • Updated the FROM line parsing to remove the AS part for case-insensitive comparison.
  • This ensures compatibility with Dockerfiles using multistage builds.

@Sainomori Sainomori force-pushed the issue-103-allow-multistage branch 2 times, most recently from f94e9a0 to 73cff33 Compare May 29, 2024 08:13
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarCloud

Sainomori and others added 2 commits February 11, 2026 21:45
…dation

- Modified the validate_docker_compose_yml function to support multistage Dockerfiles.
- Updated the FROM line parsing to remove the AS <stage name> part for case-insensitive comparison.
- This ensures compatibility with Dockerfiles using multistage builds.
Prevent file handle leak by wrapping the Dockerfile open() call in a with statement. Update test mocks to support context manager protocol.
@arnaugiralt arnaugiralt force-pushed the issue-103-allow-multistage branch from 73cff33 to 0887be3 Compare February 11, 2026 21:03
@arnaugiralt
Copy link
Copy Markdown
Member

This PR is still useful, so I rebased it against master and fixed a couple of things:

  • Prevent file handle leak by wrapping the Dockerfile open() call in a with statement. Update test mocks to support context manager protocol.
  • The regex r'\s+AS\s+.*' used to strip AS <stage> from Dockerfile FROM lines was flagged by Sonar (python:S5852) for potential polynomial backtracking. Since the image is always the first token after FROM, a simple split()[0] achieves the same result without any regex.

jonatrios
jonatrios previously approved these changes Feb 27, 2026
Docker image names are case-insensitive, so the base image check
in Dockerfile validation should not fail on casing differences.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@arnaugiralt arnaugiralt merged commit 8ced550 into master Feb 28, 2026
12 checks passed
@arnaugiralt arnaugiralt deleted the issue-103-allow-multistage branch February 28, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow multistage Dockerfile

4 participants